<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button>存</button>
  <p></p>
  <script>
    const guoqi = +localStorage.getItem("time");
    const now = new Date().getTime();
    if (now > guoqi) {
      localStorage.clear()
    } else {
      document.querySelector("p").innerHTML = localStorage.getItem("username")
    }

    

    document.querySelector("button").onclick = () => {
      const username = "zhangsan";
      const password = "123456";
      const checked = true;
      const time = new Date().getTime();
      localStorage.setItem("username", username)
      localStorage.setItem("password", password)
      localStorage.setItem("checked", checked)
      localStorage.setItem("time", time + 1000 * 60)
    }
    
  </script>
</body>
</html>